<?php
/**
 * This file is part of the Agora distribution. 
 * Detailed copyright and licensing information can be found
 * in the gpl-3.0.txt file which should be included in the distribution.
 * 
 * @version		$Id: 3.0.14 Olympus 2010-09-28 rammstein4o $
 * @copyright  2007 - 2010 jVitals
 * @license   GPLv3 Open Source
 * @link       http://jvitals.com
 * @since      File available since initial release
 */
 defined ('IN_AGORA') or die;
class RanksModel extends Model
{
	function __construct()
	{
		parent::__construct('ranks');
	}

	function loadAll($key='')
	{
		$this->setOrder('ORDER BY min_posts ASC');
		return parent::loadAll($key);
	}

	function _sort_images($a, $b)
	{
		return strcmp($a['name'],$b['name']);
	}

	function loadImages()
	{
		$dir = opendir(AGORA_PATH.DS.'img'.DS.'ranks');
		$images = array();
		while ($file = readdir($dir)) {
			if (preg_match('/.+\.(gif|png|jpg|jpeg)/i',$file)) {
				$images[] = array(
					'name'=> $file,
					'url' => Agora::getSite().'img/ranks/'.$file,
				);
			}
		}
		usort($images, array($this,'_sort_images'));
		closedir($dir);
		return $images;
	}
}
?>
